//
//  PInformationCell.m
//  Tiger
//
//  Created by 龚 杰 on 12-7-5.
//  Copyright (c) 2012年 __MyCompanyName__. All rights reserved.
//

#import "PInformationCell.h"


#define k_PicUrl		@"picUrl"
#define k_Name			@"cateName"
#define k_DatedAt		@"updatedAt"
#define k_Title			@"title"
#define k_Content		@"content"

@implementation PInformationCell
@synthesize newsID;
@synthesize m_PicURL;

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        // Initialization code
        
        m_tImgs =[[AsyncImageView alloc] initWithFrame:CGRectMake(10, 10, 280, 280)];
        [self.contentView addSubview:m_tImgs];
   
//        m_name = [[UILabel alloc] initWithFrame:CGRectMake(15, 165, 270, 18)];
//        [m_name setBackgroundColor:[UIColor clearColor]];
//        [m_name retain];
//        m_name.tag = 0x80;
//       	m_name.font = [UIFont boldSystemFontOfSize:15];
//		m_name.textColor = [UIColor blackColor];
//        [self.contentView addSubview:m_name];
//
//        
//        m_content = [[UILabel alloc] initWithFrame:CGRectMake(12, 190, 270, 100)];
//        [m_content setBackgroundColor:[UIColor clearColor]];
//        m_content.font = [UIFont systemFontOfSize:12.0f];
//        m_content.textColor = [UIColor blackColor];
//        m_content.numberOfLines = 0;
//        [self.contentView addSubview:m_content];
        activity = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];

    }
    return self;
}

//- (void)setSelected:(BOOL)selected animated:(BOOL)animated
//{
//    [super setSelected:selected animated:animated];
//
//    // Configure the view for the selected state
//}


#pragma mark Private
- (void)sendRequestPayInfo
{
        //GET 请求
//        NSString *getURL = [NSString stringWithFormat:@"http://www.speedtiger.com.cn/ios3/news_detail.html?id=%d", self.newsID];
        //NSLog(@"发送注册请求URL：%@", getURL);
    m_tImgs._imageRequestURL = m_PicURL;
    m_tImgs._numStateRequested = need_Request;
    m_tImgs.m_BoolSetImage = YES;
    [m_tImgs customLoadImageFromURL];
//        ASIHTTPRequest *request = [[ASIHTTPRequest alloc] initWithURL:[NSURL URLWithString:m_PicURL]];
//        request.tag = -1;
//        [request setValidatesSecureCertificate:NO];
//        [request setDelegate:self];
//        [request startAsynchronous];
//        activity.frame = CGRectMake(self.frame.size.width/2-20, 140, 20, 20);
//        [self.contentView addSubview:activity];
//        [activity startAnimating];
//        NSLog(@"tag = %d",self.tag);
}


//#pragma mark ASIHTTPRequestDelegate methods
//- (void)requestStarted:(ASIHTTPRequest *)request
//{
//	[UIApplication sharedApplication].networkActivityIndicatorVisible = YES;
//}

//- (void)requestFinished:(ASIHTTPRequest *)request
//{
//	NSData *responseData = [request responseData];
//	NSString *responseStr = [[[NSString alloc] initWithData:responseData encoding: NSUTF8StringEncoding] autorelease];
    
	//NSLog(@"responseStr %@", responseStr);
//	if (request.tag < 0) {
//        [m_tImgs set]
//        
//        NSDictionary *dict = [responseStr JSONValue];
//		//NSLog(@"dict %@", dict);
//        
//		NSString *picURL = [dict objectForKey:k_PicUrl];
//		if(picURL){
//			NSURL *url=[NSURL URLWithString:picURL];
//			[m_tImgs setImageWithURL:url];
			

//            m_tImgs._numStateRequested = need_Request;
//            m_tImgs._imageRequestURL = url;
//            NSLog(@"%@",m_tImgs._imageRequestURL);
//            m_tImgs.m_BoolSetImage = YES;
//            [m_tImgs customLoadImageFromURL];
       

//		}
		
//       m_name.text= [dict objectForKey:k_Title];
//		m_name.text = [dict objectForKey:k_Name];
//		dataLable.text = [dict objectForKey:k_DatedAt];
//		m_content.text = [dict objectForKey:k_Content];
//        [activity stopAnimating]; 
		//NSLog(@"content = %@",content);
//		[self.tableView reloadData];
//	}
//	else {
//		NSLog(@"recved bad data !");
//	}
//}

//- (void)requestFailed:(ASIHTTPRequest *)request
//{
//	[UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
//	[activity stopAnimating]; 
//    
//	UIAlertView *alert = [[[UIAlertView alloc] initWithTitle:@"温馨提示" 
//													 message:@"无可用的网络连接" 
//													delegate:self 
//										   cancelButtonTitle:nil 
//										   otherButtonTitles:nil] autorelease];
//	[alert addButtonWithTitle:@"确定"];
//	[alert show];
//}

- (void)dealloc
{
//    [m_name release];
//    [m_content release];
    [m_tImgs release];
    [activity release];
    [super dealloc];
}

@end
